#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

typedef int STDataType;
typedef  struct Stack
{
    STDataType* arr;
    int size;
    int capacity;
}ST;

void STInit(ST* ps)
{
    assert(ps);
    STDataType* tmp=(STDataType*)malloc(5 * sizeof(STDataType));
    assert(tmp);
    ps->arr = tmp;
    ps->size = 0;
    ps->capacity = 0;
}

void STDestory(ST* ps)
{
    assert(ps);
    if (ps->arr)
    {
        free(ps->arr);
        ps->arr = NULL;
        ps->size = ps->capacity = 0;
    }
}

 void CheakCapacity(ST* ps)
 {
     assert(ps);
     if(ps->size==ps->capacity)
     {
         int newcapacity=(ps->capacity==0?4:ps->capacity*2);
         STDataType* tmp=(STDataType*)realloc(ps->arr,newcapacity*sizeof(STDataType));
         if(tmp==NULL)
         {
             perror("realloc fail");
             exit(-1);
         }
         ps->arr=tmp;
         ps->capacity=newcapacity;
     }
 }

void STPushStack(ST* ps, STDataType x)
{
    assert(ps);
    CheakCapacity(ps);
    ps->arr[ps->size] = x;
    ps->size++;
}

void STPopStack(ST* ps)
{
    assert(ps);
    assert(ps->size > 0);
    ps->size--;
}

STDataType STStackTop(ST* ps)
{
    assert(ps);
    assert(ps->size > 0);
    return ps->arr[ps->size - 1];
}

bool STEmpty(ST* ps)
{
    assert(ps);
    return ps->size == 0;
}

int main()
{
    int m = 0;
    int n = 0;
    int k = 0;
    scanf("%d %d %d", &m, &n, &k);
    while (k--)
    {
        ST st;
        STInit(&st);
        int arr[1000] = { 0 };
        int i = 0;
        int elm = 0;
        int flag = 0;
        for (i = 0; i < n; i++)
        {
            scanf("%d", &arr[i]);
            while (elm < arr[i])
            {
                elm++;
                STPushStack(&st, elm);
            }
            if (st.size > m)
                flag = 1;
            if(arr[i] == STStackTop(&st))
                STPopStack(&st);
        }
        if (flag || st.size)
            printf("NO\n");
        else
            printf("YES\n");
        STDestory(&st);
    }
    return 0;
}